package sonic.game.item;
import java.awt.Graphics;

import sonic.game.Game;
import sonic.game.animation.Animation;
import sonic.game.tile.DynamicTile;
import sonic.game.util.Vector2D;

/**
 * Game Item
 * 
 * Base class for items
 * 
 * @author Richard Greenlees
 *
 */

public class GameItem extends DynamicTile {

	protected Animation idleAnim;
	protected Animation activeAnim;
	protected Animation currentAnim;
	
	public GameItem(float startX, float startY)
	{
		super();
		setLocation(startX, startY);
		currentAnim = idleAnim;
	}
	
	public GameItem(Vector2D startPos)
	{
		super(startPos);
		currentAnim = idleAnim;
	}
	
	public void activate()
	{
		
	}
	
	public void update(double deltaTime)
	{
		super.update(deltaTime);
		if (currentAnim != null)
		{
			currentAnim.update(deltaTime);
		}
	}
	
	public void updateBounds()
	{		
		try
		{
			tileCorners[0] = new Vector2D(location.x, location.y);
			tileCorners[1] = new Vector2D(location.x + collisionBoxX, location.y);
			tileCorners[2] = new Vector2D(location.x + collisionBoxX, location.y + collisionBoxY);
			tileCorners[3] = new Vector2D(location.x, location.y + collisionBoxY);
		}
		catch (NullPointerException e)
		{

		}
	}
	
	public void paint(Graphics g)
	{
		if (currentAnim != null)
		{
			g.drawImage(currentAnim.getCurrentFrame(), (int) location.x + (320-(int) Game.camera.location.x), (int) location.y + (240-(int) Game.camera.location.y), null);
		}
	}
	
}
